package com.itheima.example;

import java.io.*;

public class Example04 {
    public static void main(String[] args) throws Exception {
        FileInputStream input = new FileInputStream("source//IMG_7799.jpg");
        FileOutputStream output = new FileOutputStream("target//IMG_7799.jpg");
        byte[] buffer = new byte[1024]; // 定义一个字节数组作为缓冲区
        int length;
        long startTime = System.currentTimeMillis();
        while ((length = input.read(buffer)) != -1) {
            output.write(buffer, 0, length);
        }
        long endTime = System.currentTimeMillis();
        System.out.println("复制图片所消耗的时间是:" + (endTime - startTime) + "毫秒");
        input.close();
        output.close();
    }
}
